from selenium import webdriver
from selenium.webdriver.common.by import By
import time

class BrowserOperation():
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://www.baidu.com')

    def quit(self):
        time.sleep(2)
        self.driver.quit()

    def window_size(self):
        for i in  range(3):
            self.driver.set_window_size(480,800)

            time.sleep(2)
            self.driver.maximize_window()

            time.sleep(2)
            self.driver.minimize_window()

    def window_refresh(self):
        time.sleep(2)
        self.driver.refresh()

    def window_close(self):
        time.sleep(2)
        news = self.driver.find_element(By.LINK_TEXT,'新闻')
        news.click()
        time.sleep(2)
        self.driver.close()




if __name__=='__main__':
    bro = BrowserOperation()
    # bro.window_size()
    # bro.window_refresh()
    bro.window_close()
    bro.quit()
